#include <iostream>
#include <unordered_map>

using namespace std;

class Solution {
public:
    string minWindow(string s, string t) {
        unordered_map<char, int> map;
        for (char& c : t) {
            map[c]++;
        }
        int i = 0;
        int j = 0;
        int len = INT32_MAX;
        int ans_i = 0;
        int cnt = 0;
        for (; j < s.size(); j++) {
            map[s[j]]--;
            if (map[s[j]] >= 0) {
                cnt++;
            }
            while (cnt == t.size()) {
                map[s[i]]++;
                if (map[s[i]] > 0) {
                    cnt--;
                }
                if (j - i + 1 < len) {
                    len = j - i + 1;
                    ans_i = i;
                }
                i++;
            }
        }
        return len == INT32_MAX ? "" : s.substr(ans_i, len);
    }
};

int main() {
    Solution solution;
    string output = solution.minWindow("ADOBECODEBANC", "ABC");
    cout << output << endl;
}